//PA2-1
#ifdef DATA_BYTE
#include "cpu/exec/template-start.h"

#define instr setcc

static inline bool take_cond(uint32_t opcode) {
    uint32_t cc = opcode & 0xF;
    switch (cc) {
        case 0x0: return cpu.eflags.OF;                /* O */
        case 0x1: return !cpu.eflags.OF;               /* NO */
        case 0x2: return cpu.eflags.CF;                /* B/NAE/C */
        case 0x3: return !cpu.eflags.CF;               /* NB/AE/NC */
        case 0x4: return cpu.eflags.ZF;                /* Z/E */
        case 0x5: return !cpu.eflags.ZF;               /* NZ/NE */
        case 0x6: return cpu.eflags.CF || cpu.eflags.ZF; /* BE/NA */
        case 0x7: return !cpu.eflags.CF && !cpu.eflags.ZF; /* A/NBE */
        case 0x8: return cpu.eflags.SF;                /* S */
        case 0x9: return !cpu.eflags.SF;               /* NS */
        case 0xA: return cpu.eflags.PF;                /* P/PE */
        case 0xB: return !cpu.eflags.PF;               /* NP/PO */
        case 0xC: return cpu.eflags.SF != cpu.eflags.OF;  /* L/NGE */
        case 0xD: return cpu.eflags.SF == cpu.eflags.OF;  /* NL/GE */
        case 0xE: return cpu.eflags.ZF || (cpu.eflags.SF != cpu.eflags.OF); /* LE/NG */
        case 0xF: return !cpu.eflags.ZF && (cpu.eflags.SF == cpu.eflags.OF); /* NLE/G */
    }
    return false;
}

static void do_execute() {
    uint8_t v = take_cond(ops_decoded.opcode) ? 1 : 0;
    OPERAND_W(op_dest, v);
    print_asm("setcc %s", op_dest->str);
}

make_instr_helper(rm)

#include "cpu/exec/template-end.h"
#endif


